// To parse this JSON data, do
//
//     final paymentRecordIcr = paymentRecordIcrFromJson(jsonString);

import 'dart:convert';

PaymentRecordIcr paymentRecordIcrFromJson(String str) =>
    PaymentRecordIcr.fromJson(json.decode(str));

String paymentRecordIcrToJson(PaymentRecordIcr data) =>
    json.encode(data.toJson());

class PaymentRecordIcr {
  PaymentRecordIcr({
    this.transactions,
    this.currentPlanId,
  });

  List<Transaction>? transactions;
  String? currentPlanId;

  factory PaymentRecordIcr.fromJson(Map<String, dynamic> json) =>
      PaymentRecordIcr(
        transactions: json["transactions"] == null
            ? []
            : List<Transaction>.from(
                json["transactions"]!.map((x) => Transaction.fromJson(x))),
        currentPlanId: json["currentPlanId"],
      );

  Map<String, dynamic> toJson() => {
        "transactions": transactions == null
            ? []
            : List<dynamic>.from(transactions!.map((x) => x.toJson())),
        "currentPlanId": currentPlanId,
      };
}

class Transaction {
  Transaction({
    this.amount,
    this.createdAt,
    this.creditCard,
    this.currencyIsoCode,
    this.discounts,
    this.planId,
    this.processorResponseText,
    this.settlementBatchId,
    this.status,
    this.type,
    this.updatedAt,
    this.paymentInstrumentType,
  });

  int? amount;
  int? createdAt;
  CreditCard? creditCard;
  String? currencyIsoCode;
  List<Discount>? discounts;
  String? planId;
  String? processorResponseText;
  String? settlementBatchId;
  String? status;
  String? type;
  int? updatedAt;
  String? paymentInstrumentType;

  factory Transaction.fromJson(Map<String, dynamic> json) => Transaction(
        amount: json["amount"],
        createdAt: json["createdAt"],
        creditCard: json["creditCard"] == null
            ? null
            : CreditCard.fromJson(json["creditCard"]),
        currencyIsoCode: json["currencyIsoCode"],
        discounts: json["discounts"] == null
            ? []
            : List<Discount>.from(
                json["discounts"]!.map((x) => Discount.fromJson(x))),
        planId: json["planId"],
        processorResponseText: json["processorResponseText"],
        settlementBatchId: json["settlementBatchId"],
        status: json["status"],
        type: json["type"],
        updatedAt: json["updatedAt"],
        paymentInstrumentType: json["paymentInstrumentType"],
      );

  Map<String, dynamic> toJson() => {
        "amount": amount,
        "createdAt": createdAt,
        "creditCard": creditCard?.toJson(),
        "currencyIsoCode": currencyIsoCode,
        "discounts": discounts == null
            ? []
            : List<dynamic>.from(discounts!.map((x) => x.toJson())),
        "planId": planId,
        "processorResponseText": processorResponseText,
        "settlementBatchId": settlementBatchId,
        "status": status,
        "type": type,
        "updatedAt": updatedAt,
        "paymentInstrumentType": paymentInstrumentType,
      };
}

class CreditCard {
  CreditCard({
    this.bin,
    this.cardType,
    this.customerLocation,
    this.expirationMonth,
    this.expirationYear,
    this.maskedNumber,
    this.expirationDate,
  });

  String? bin;
  String? cardType;
  String? customerLocation;
  String? expirationMonth;
  String? expirationYear;
  String? maskedNumber;
  String? expirationDate;

  factory CreditCard.fromJson(Map<String, dynamic> json) => CreditCard(
        bin: json["bin"],
        cardType: json["cardType"],
        customerLocation: json["customerLocation"],
        expirationMonth: json["expirationMonth"],
        expirationYear: json["expirationYear"],
        maskedNumber: json["maskedNumber"],
        expirationDate: json["expirationDate"],
      );

  Map<String, dynamic> toJson() => {
        "bin": bin,
        "cardType": cardType,
        "customerLocation": customerLocation,
        "expirationMonth": expirationMonth,
        "expirationYear": expirationYear,
        "maskedNumber": maskedNumber,
        "expirationDate": expirationDate,
      };
}

class Discount {
  Discount({
    this.amount,
    this.currentBillingCycle,
    this.description,
    this.id,
    this.kind,
    this.quantity,
    this.name,
    this.numberOfBillingCycles,
    this.planId,
  });

  double? amount;
  int? currentBillingCycle;
  dynamic description;
  String? id;
  dynamic kind;
  int? quantity;
  String? name;
  int? numberOfBillingCycles;
  dynamic planId;

  factory Discount.fromJson(Map<String, dynamic> json) => Discount(
        amount: json["amount"]?.toDouble(),
        currentBillingCycle: json["currentBillingCycle"],
        description: json["description"],
        id: json["id"],
        kind: json["kind"],
        quantity: json["quantity"],
        name: json["name"],
        numberOfBillingCycles: json["numberOfBillingCycles"],
        planId: json["planId"],
      );

  Map<String, dynamic> toJson() => {
        "amount": amount,
        "currentBillingCycle": currentBillingCycle,
        "description": description,
        "id": id,
        "kind": kind,
        "quantity": quantity,
        "name": name,
        "numberOfBillingCycles": numberOfBillingCycles,
        "planId": planId,
      };
}
